package main.java.design.state;

/**
 * <p>
 * 它定义了客户程序需要的接口并维护一个具体状态角色的实例，将与状态相关的操作委托给当前的Concrete State对象来处理。
 * </p>
 *
 * @author : wangdejian
 * @version 1.0
 * @date : 2020/6/26 16:45
 */
public class GameContext {

    private HeroState heroState;

    public static final SpeedUpState SPEED_UP_STATE = new SpeedUpState();
    public static final SlowDownState SLOW_DOWN_STATE = new SlowDownState();
    public static final VertigoState VERTIGO_STATE = new VertigoState();
    public static final FearState FEAR_STATE = new FearState();


    public HeroState getHeroState() {
        return heroState;
    }

    public void setHeroState(HeroState heroState) {
        this.heroState = heroState;
        this.heroState.setGameContext(this);
    }

    //加速
    public void speedUp() {
        this.heroState.speedUp();
    }

    //减速
    public void slowDown() {
        this.heroState.slowDown();
    }

    // 眩晕
    public void vertigo() {
        this.heroState.vertigo();
    }

    // 恐惧
    public void fear() {
        this.heroState.fear();
    }
}
